﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Police
{
    /// <summary>
    /// Mark class as validation rule. If class is marked as validator but not implement
    /// <see cref="Police.IPreCommitRule"/>, Police throw an invalid operation exception.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public sealed class PreCommitRuleAttribute : Attribute
    {
        /// <summary>
        /// Gets or set rule name.
        /// </summary>
        public String RuleName { get; private set; }

        /// <summary>
        /// Gets or sets order.
        /// </summary>
        public int Order { get; private set; }

        /// <summary>
        /// Gets or sets if rule is enabled.
        /// </summary>
        public Boolean Enabled { get; private set; }

        private PreCommitRuleAttribute() 
        {
            RuleName = String.Empty;
            Order = 0;
            Enabled = true;
        }

        /// <summary>
        /// Initialize new PreCommitRule.
        /// </summary>
        /// <param name="ruleName"></param>
        /// <param name="order"></param>
        /// <param name="enabled"></param>
        public PreCommitRuleAttribute(String ruleName, int order, Boolean enabled = true)
            : this()
        {
            RuleName = ruleName;
            Order = order;
            Enabled = enabled;
        }
    }
}
